fix(docs): add fallback chain for geo IP detection - #184
Merged
Conversation
The boce.com geo IP endpoint is frequently unreachable, which silently disables the CN-site redirect prompt. Try myip.ipip.net and api.ip.sb first, falling back to boce.com only as a last resort.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
中文版模板 / Chinese template
🤔 This is a ...
🔗 Related Issues
💡 Background and Solution
The docs site asks mainland-China visitors whether they want to be redirected to
x.antdv-next.cn. The geo lookup relied on a single endpoint,https://v4_dx.boce.com:44433/ipaddr, which is frequently unreachable (non-standard port, unstable availability). Whenever it fails,getChinaMainlandRedirectDecision()returnsskipand the redirect prompt never appears for the users it was built for.This PR replaces the single endpoint with an ordered fallback chain. Each API is tried in turn; the first one that responds successfully decides the outcome, and probing stops there — a successful non-CN result does not fall through to the next provider. If every request fails, the behaviour is unchanged: return
skipsilently so the page is never blocked.The chain, in order:
https://myip.ipip.net中国香港/中国澳门/中国台湾.https://api.ip.sb/geoipcountry_codeHK/TW/MOare distinct fromCN, so no extra filtering is needed.https://v4_dx.boce.com:44433/ipaddrdata.fromParsing is now per-API via a
parse(text: string) => booleanhook, so each provider owns its own response format, and the timeout was raised from 1200ms to 1500ms per attempt to reduce false negatives on slow connections.No user-facing API changed — this only affects the docs site's internal geo detection.
📝 Change Log